#include<stdio.h>

int main()
{
    int n;
    double m;
    scanf("%d,%lf", &n, &m);
    int sum = 1;
    n--;
    double x = 2;
    while (n--)
    {
        x *= m;
        double t = x / 3;
        if (t - (int)t == 0)
            sum += t;
        else sum += t + 1;

    }
    printf("%d", sum);
    return 0;
}